public class TreeNode {
         int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int x) { val = x; }
 }

class Solution {
    public boolean helper(TreeNode rootLeft,TreeNode rootRight) {
        if (rootLeft == null && rootRight == null) return true;
        if (rootLeft == null || rootRight == null) return  false;
        if (rootLeft.val != rootRight.val) return false;
        return helper(rootLeft.left,rootRight.right) && helper(rootLeft.right,rootRight.left);
    }
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return helper(root.left,root.right);
    }
}